<template>
<div class="home">
    <div v-if="formData.cardno">
        <div class="czInfo">
            <div>企业信息</div>
        </div>
        <van-field
                input-align="right"
                label="企业名称"
                v-model="formData.qy_name"
                readonly
        />
        <van-field
                input-align="right"
                label="企业归属地"
                v-model="formData.gsdName"
                readonly
        />
        <div class="czInfo">
            <div>闭环管理责任人</div>
        </div>
        <van-field
                input-align="right"
                label="身份证号"
                v-model="formData.cardno"
                readonly
        />
        <van-field
                input-align="right"
                label="姓名"
                v-model="formData.name"
                readonly
        />
        <van-field
                input-align="right"
                label="电话号码"
                v-model="formData.tel"
                readonly
        />
        <van-field
                input-align="right"
                label="收货地址"
                v-model="formData.fh_address"
                readonly
        />
        <van-field
                input-align="right"
                label="到沈时间"
                v-model="formData.arrive_time"
                readonly
        />
        <van-field
                input-align="right"
                label="预计离沈时间"
                v-model="formData.ls_time"
                readonly
        />
        <van-field
                input-align="right"
                label="车牌号码"
                v-model="formData.car_number"
                readonly
        />
        <van-field
                input-align="right"
                label="车牌颜色"
                v-model="formData.chepai_color_name"
                readonly
        />
        <van-field
                input-align="right"
                label="驾驶员姓名"
                v-model="formData.driver_name"
                readonly
        />
        <van-field
                input-align="right"
                label="驾驶员电话"
                v-model="formData.driver_tel"
                readonly
        />
        <van-field
                input-align="right"
                label="驾驶员身份证"
                v-model="formData.driver_cardno"
                readonly
        />
        <div class="czInfo" v-show="formData.peerList.length > 0">
            <div>同行人员</div>
        </div>
        <div v-for="(item, index) in formData.peerList" :key="index">
            <div :class="{'txClass': formData.peerList.length > 1}">
                <van-field
                input-align="right"
                :label="'姓名' + (index + 1)"
                v-model="item.passenger_name"
                readonly
            />
            <van-field
                input-align="right"
                :label="'电话' + (index + 1)"
                v-model="item.passenger_tel"
                readonly
            />
            <van-field
                input-align="right"
                :label="'身份证号' + (index + 1)"
                v-model="item.passenger_cardno"
                readonly
            />
            </div>
        </div>
    </div>
</div>
</template>
<script>
import {
  getQyBaByCode
} from '@/api/gov/home/index'
import { Toast } from 'vant'
// import moment from 'moment'
export default {
  name: 'component_name',
  data () {
    return {
      code: '',
      formData: {},
      projectListArr: [
        {
          value: '1',
          lable: '蓝色'
        },
        {
          value: '2',
          lable: '黄色'
        },
        {
          value: '3',
          lable: '黑色'
        },
        {
          value: '4',
          lable: '白色'
        },
        {
          value: '5',
          lable: '绿色'
        },
        {
          value: '9',
          lable: '其他'
        }
      ],
      columnsAdress: [
        {
          'code': 'LM00001',
          'name': '和平区'
        },
        {
          'code': 'LM00002',
          'name': '沈河区'
        },
        {
          'code': 'LM00003',
          'name': '大东区'
        },
        {
          'code': 'LM00004',
          'name': '皇姑区'
        },
        {
          'code': 'LM00005',
          'name': '铁西区'
        },
        {
          'code': 'LM00006',
          'name': '浑南区'
        },
        {
          'code': 'LM00007',
          'name': '于洪区'
        },
        {
          'code': 'LM00008',
          'name': '沈北新区'
        },
        {
          'code': 'LM00009',
          'name': '苏家屯区'
        },
        {
          'code': 'LM00010',
          'name': '辽中区'
        },
        {
          'code': 'LM00011',
          'name': '康平县'
        },
        {
          'code': 'LM00012',
          'name': '法库县'
        },
        {
          'code': 'LM00013',
          'name': '新民市'
        }
      ]
    }
  },
  mounted () {
    this.code = this.$route.query.register_code
    this.getQyBaByCode()
  },
  methods: {
    getQyBaByCode () {
      getQyBaByCode({ register_code: this.code }).then((res) => {
        if (res.data.errcode == 0) {
          const obj = res.data.data
          if (obj.chepai_color) {
            obj.chepai_color_name = this.projectListArr.find(e => e.value == obj.chepai_color).lable
          }
          if (obj.gsd) {
            obj.gsdName = this.columnsAdress.find(e => e.code == obj.gsd).name
          }
          this.formData = obj
          console.log('obj', obj)
        } else {
          Toast.fail(res.data.errmsg)
        }
      })
    }
  }
}
</script>
<style scoped lang="less">
.home {
  width: 100%;
  overflow-x: hidden;
  /deep/.van-field__label {
    width: 9em;
    display: flex;
    align-items: center;
  }
  /deep/.van-field__error-message {
    text-align: right;
  }
  .btn {
    height: 80px;
    background: #f1f3f4;
    font-size: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    span {
      margin-left: 10px;
      vertical-align: middle;
    }
  }
  .txClass{
      border-bottom: 20px solid #f1f3f4;
  }
}
.czInfo {
  height: 80px;
  font-size: 32px;
  //font-weight: bold;
  //color: white;
  //background-color: #58be6a;
  background-color: #eee;
  display: flex;
  align-items: center;
  div {
    width: 690px;
    margin: 0 auto;
  }
}
</style>
